<?php
/**
 * Contus Support Interactive.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file PRICE COUNTDOWN-LICENSE.txt.
 *
 * =================================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * =================================================================
 * This package designed for Magento 1.4.x, 1.5.x, 1.6.x and 1.7.x COMMUNITY edition
 * Contus Support does not guarantee correct work of this package
 * on any other Magento edition except Magento 1.4.x, 1.5.x, 1.6.x and 1.7.x COMMUNITY edition.
 * =================================================================
 */
?>
<?php
/* Count for timer calculation declared here */
$count = 1;
$_product = $this->getProduct();
$toDate = $_product->getSpecialTODate();

/* Admin Controllers for timer are declared here */
$timer_active = Mage::getStoreConfig('timer/general/activate_apptha_timer');
$timer_head_active = Mage::getStoreConfig('timer/general/activate_apptha_heading');
$timer_desc_active = Mage::getStoreConfig('timer/general/activate_apptha_description');
$desc_color = Mage::getStoreConfig('timer/apptha_timer_color/description');
$timer_color = Mage::getStoreConfig('timer/apptha_timer_color/text');
$head_color = Mage::getStoreConfig('timer/apptha_timer_color/heading_text_color');
$timer_head = Mage::getStoreConfig('timer/general/heading');
?>

<?php $_wishlistSubmitUrl = $this->helper('wishlist')->getAddUrl($_product); ?>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
    <li><a href="<?php echo $_wishlistSubmitUrl ?>" onclick="productAddToCartForm.submitLight(this, '<?php echo $_wishlistSubmitUrl ?>'); return false;" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php
    $_compareUrl = $this->helper('catalog/product_compare')->getAddUrl($_product);
?>
<?php if ($_compareUrl) : ?>
        <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>

<!--Condition for Timer Controllers goes here-->
<?php if ($timer_active == 1) : ?>
<?php if ($_product->getPrice() > $_product->getSpecialPrice()) : ?>
<?php if ($_product->getSpecialPrice() != 0 || $_product->getSpecialPrice() != "") : ?>
<?php if ($timer_head_active == 'showall' || $timer_head_active == 'viewpage' && $timer_head_active != 'hideall' && $timer_head != '') : ?>
                        <div id="heading<?php echo $count; ?>" style="color:#<?php echo $head_color; ?>; font-size: 18px; font-weight:bold;padding-top:15px;clear: both;"><?php echo $timer_head ?></div>
<?php endif; ?>
                        <div id="countbox_<?php echo $count; ?>" class="timer-view"></div>
<?php if ($timer_desc_active == 'showall' || $timer_desc_active == 'viewpage' && $timer_desc_active != 'hideall') : ?>
                        <div class='clear'></div><div class='timerdate' id="caption<?php echo $count; ?>"><span class='hour' style='margin:1px 23px 0 0px'><?php echo $this->__('Days') ?></span><span class='hour' style='margin:1px 19px 0 15px'><?php echo $this->__('Hours') ?></span><span class='min'  style='margin:1px 20px 0 7px'><?php echo $this->__('Minutes') ?></span><span class='sec' style='margin:1px 0 0 2px'><?php echo $this->__('Seconds') ?></span></div>
<?php endif;endif;endif; ?>

<?php if ($_product->getPrice() > $_product->getSpecialPrice()) : ?>
<?php if ($_product->getSpecialPrice() != 0 || $_product->getSpecialPrice() != "") : ?>
        <script type="text/javascript">
            var dthen<?php echo $count; ?> = new Date("<?php echo Date("m/d/y", strtotime($toDate)).' 11:59:00 PM'; ?>");
            start = "<?php echo Date("m/d/y h:i:s A", strtotime(Mage_Core_Model_Locale::date(null, null, "en_US", true))); ?>";
            start_date = Date.parse(start);
            var dnow<?php echo $count; ?> = new Date(start_date);
            if(CountStepper>0)
                ddiff= new Date((dnow<?php echo $count; ?>)-(dthen<?php echo $count; ?>));
            else
                ddiff = new Date((dthen<?php echo $count; ?>)-(dnow<?php echo $count; ?>));
            gsecs<?php echo $count; ?> = Math.floor(ddiff.valueOf()/1000);

            var iid<?php echo $count; ?> = "countbox_<?php echo $count; ?>";
            CountBack(gsecs<?php echo $count; ?>,"countbox_"+j, j);
            j++;
        </script>
<?php $count = $count + 1; ?>
<?php endif;endif;endif; ?>

<!--Dynamic style changes goes here-->
<style>
    .timer-view{float: left;width: 100%;padding:0;color: #<?php echo $timer_color; ?>;font-size: 40px; font-family: arial;font-weight: bold;}
    .timerdate{float: left;width: 100%;padding:0 0 15px 10px;color: #<?php echo $desc_color; ?>;font-size: 13px;}
</style>